<template>
  <div>
    <el-form ref="ruleForm" style="margin-top: 30px;" :model="link" label-width="100px">
      <el-form-item label="名称" prop="linkName">
        <el-input v-model="link.linkName" />
      </el-form-item>
      <el-form-item label="链接" prop="linkUrl">
        <el-input v-model="link.linkUrl" />
      </el-form-item>
      <el-form-item label-width="100px">
        <el-button type="primary" @click="submitForm">提交</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
import linkApi from '@/api/link'
export default {
  name: 'LinkAdd',
  props: {
    link: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
    }
  },
  created() {
  },
  methods: {
    submitForm() {
      const loading = this.$loading({
        lock: true,
        text: '添加中请稍后',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      linkApi.update(this.link).then(res => {
        if (res.code === 200) {
          this.link = res.data
          loading.close()
          this.$message.success(res.msg)
          this.$emit('closeLinkUpdateDialog')
          this.$emit('getLinkList')
        } else {
          this.$message.success(res.msg)
          loading.close()
        }
      }).catch(err => {
        console.log(err)
        loading.close()
      })
    }
  }
}
</script>

<style scoped>
</style>

